.contextual
  = icon_link_to :profit_sheet, :action => :profit_sheet, :by_date => params[:by_date], :years => params[:years]
  = icon_link_to :print, :format => :pdf, :by_date => params[:by_date], :years => params[:years]
  = contextual_links_for

%h2= t('bookyt.balance_report', :dates => @dates.join(", "), :company => [@tenant.to_s, @tenant.company.vcard.extended_address].map(&:presence).compact.join(" - ") )

%table.table.table-striped.collection{:width => "100%"}
  %thead
    %tr
      %th{:colspan => "2"}
      -for date in @dates
        %th.right
          %h2= date.last.year
    %tr
      %th{:colspan => "2"}
        %h2= t('bookyt.assets')
      -for date in @dates
        - date_range = action_name == 'balance_sheet' ? date.last : date
        %th.right
          %h2= currency_fmt(Account.by_type('current_assets').saldo(date_range) + Account.by_type('capital_assets').saldo(date_range))

  = render 'account_group_sheet', :group => 'current_assets'
  = render 'account_group_sheet', :group => 'capital_assets'
  %thead
    %tr
      %th{:colspan => "2"}
        %h2= t('bookyt.capital')
      -for date in @dates
        - date_range = action_name == 'balance_sheet' ? date.last : date
        %th.right
          %h2= currency_fmt(Account.by_type('outside_capital').saldo(date_range) + Account.by_type('equity_capital').saldo(date_range))

  %tbody
    = render 'account_group_sheet', :group => 'outside_capital'
    = render 'account_group_sheet', :group => 'equity_capital'

  %tfoot
    %tr
      %th{:colspan => "2"}
        %h3= t('bookyt.difference')

      - for date in @dates
        - date_range = action_name == 'balance_sheet' ? date.last : date
        %th{:style => "text-align: right"}
          %h3= currency_fmt(Account.by_type('current_assets').saldo(date_range) + Account.by_type('capital_assets').saldo(date_range) - Account.by_type('outside_capital').saldo(date_range) - Account.by_type('equity_capital').saldo(date_range))

= render 'filters/by_fiscal_year'
